% This is to read *_raw.mat to display 2D data for publication
close all
clearvars
clc

MATfile={
    'SMFe01_scan49_raw.mat';   % NO KCl, FeCl3 40uM + SPM
    'SMFe01_scan95_raw.mat';  % + KCl (droplet in diffusion), FeCl3 40uM + SPM
    'SMFe01_scan127_raw.mat'; % + KCl (droplet stable), FeCl3 40uM + SPM
    }

FileSelect=4;

data=load(MATfile{FileSelect});
mon=data.mon;
qz=data.qz;

%change qz
qz_new = qz/0.0218;

ct=data.ct;
energy=data.energy;
mca=data.mca;
rng=energy<8.1 & energy>1.9;
% rng=energy>6 & energy< 7.5;
% rng=energy>12;
smear=ones(5,1);
mca_new=convn(mca,smear,'same');
mca_conv = log (mca_new + 1) ;


contourf(qz_new,energy(rng),mca_conv(rng,:),[0:1:5],'LineColor', 'none');


colorbar;
% Additional plot settings
colorbarHandle = colorbar;
set(colorbarHandle, 'TickDirection', 'out');   % Set colorbar ticks to 'out'
set(colorbarHandle, 'LineWidth', 2);           % Set colorbar boundary and tick thickness
set(colorbarHandle, 'FontName', 'Arial');
set(colorbarHandle, 'FontSize', 25);% Set the colorbar font to Arial
% set(colorbarHandle, 'Ticks', [0 1 2 3 4]);

set(gca, 'FontName', 'Arial'); % Set the axes font to Arial
set(gca, 'ydir', 'normal');
set(gca, 'ytick', [2:1:14]);
set(gca, 'ylim', [2 7.5]);
set(gca, 'xlim', [0.46 1.6]);
% set(gca, 'xtick', [0.01:0.005:0.035]);
set(gca, 'fontsize', 25);
set(gca, 'LineWidth', 2);
set(gca, 'TickDir', 'out');
xlabel('${\alpha_i}/{\alpha_c}$', 'Interpreter', 'latex', FontSize = 35);
ylabel('Energy (keV)',FontSize=30);

axis square
%grid on







